/**
 * 上海中赢金融信息服务有限公司
 * Copyright (c) 2017-2027 Chinazyjr,Inc.All Rights Reserved.
 */
package com.sys.midware.hadoop.hdfs;

import org.apache.hadoop.conf.Configuration;

import com.sys.midware.hadoop.config.HadoopConfigHolder;
import com.sys.midware.hadoop.config.HadoopConfigUtil;
import com.sys.midware.logger.Logger;
import com.sys.midware.logger.LoggerFactory;

/**
 * 
 * <b>ClassName：</b> HBaseDBFactory <br/>
 * <b>Description：</b> TODO <br/>
 * <b>@author：</b> mobing <br/>
 * <b>@date：</b> 2015年10月26日 下午3:40:39 <br/>
 * <b>@version: </b> <br/>
 */
public class HDFSFactory {
    private static final Logger logger = LoggerFactory.getLogger(HDFSFactory.class);

    private static HDFSFactory facotry = new HDFSFactory();

    private HDFSFactory() {

    }

    public static HDFSFactory createFactory() {
        return facotry;
    }

    private Configuration initHDFSConfiguration() {
        HadoopConfigUtil.initConfig();
        String libpath = System.getProperty("java.library.path");
        logger.info("libpath=" + libpath);

        // 设置hadoopconfig
        Configuration HADOOP_CONF = new Configuration();
        // HADOOP_CONF.set("mapred.job.tracker", "192.168.102.136:9001");
        HADOOP_CONF.set("fs.defaultFS", HadoopConfigHolder.get().getHdfsURI());

        return HADOOP_CONF;
    }

    public HDFSHandler getHDFSHandler() throws Exception {
        
        return new HDFSHandler(initHDFSConfiguration());
    }

    public void shutdown() throws Exception {
        facotry = null;
    }

}
